import ajax from '@/libs/ajax'

/**
 * 登录
 * @param data.phone(*)
 * @param data.password(*)
 * @constructor
 */
const API_LOGIN = (data) => ajax('/account/login', 'post', data)

/**
 * 注册
 * @param data.phone(*)
 * @param data.password(*)
 * @param {*} data
 */
const API_REGISTER = (data) => ajax('/account/register?phone=' + data.phone + '&password=' + data.password + '&code=' + data.code, 'post', {})

// 重置密码

const API_RESET_PASSWORD = (data) => ajax('/account/resetPassowrd?phone=' + data.phone + '&newPassword=' + data.newPassword + '&code=' + data.code, 'post', {})

// 获取注册验证码

const API_SEND_REGISTER_MSG = (phone) => ajax('/account/sendRegisterMsg?phone=' + phone, 'post', {})

// 获取忘记密码验证码

const API_SEND_RESET_MSG = (phone) => ajax('/account/sendResetMsg?phone=' + phone, 'post', {})

// 认证
const API_CERTIFICATE = (data) => ajax('/v1/userInfo/bindPhone', 'post', data)

const API_CERTIFICATE_MSG = (phone) => ajax('/v1/userInfo/sendBindPhoneMsg', 'post', { phone })

/**
 * 微信快速登录
 * @param data.openId(*)
 * @param {object} data
 */
const API_FAST_LOGIN = (openId) => ajax('/account/fastLogin', 'post', { openId })

const API_REFRESHTOKEN = (data) => ajax('/account/oauth2/refresh_token', 'get', data)

export {
  API_LOGIN,
  API_REGISTER,
  API_FAST_LOGIN,
  API_REFRESHTOKEN,
  API_SEND_REGISTER_MSG,
  API_SEND_RESET_MSG,
  API_RESET_PASSWORD,
  API_CERTIFICATE,
  API_CERTIFICATE_MSG
}
